package cn.wsalix.shiro.seesion;

import org.apache.shiro.session.ExpiredSessionException;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.SessionKey;
import org.apache.shiro.session.mgt.SimpleSession;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class NutWebSessionManager extends DefaultWebSessionManager {
	private static final Logger logger = LoggerFactory
			.getLogger(NutWebSessionManager.class);

	@Override
	protected void onChange(Session session) {
		if (session instanceof SimpleSession) {
			SimpleSession simpleSession = (SimpleSession) session;
			if(simpleSession.isExpired()){
				logger.info("isExpired:TRUE");
			}
			//logger.info("isExpired:" + simpleSession.isExpired());
		}
		//logger.info(session.getClass() + "," + session.getId() + ","
			//	+ session.getHost() + "," + session.getTimeout());
		super.onChange(session);
	}

	@Override
	protected void onExpiration(Session s, ExpiredSessionException ese,
			SessionKey key) {
		// TODO Auto-generated method stub
		super.onExpiration(s, ese, key);
	}

}
